package com.leetcode.Offer;

public class JZ56_II {
    public int singleNumber(int[] nums) {

        int[] ints = new int[32];
        for (int num : nums) {
            for (int i = 0; i < 32; i++) {
                ints[i] += (num&(1<<i)) != 0 ? 1 : 0;
            }
        }
/*        for (int anInt : ints) {
            System.out.print(anInt + ",");
        }*/
        int rs = 0;
        for (int i = 0; i < 32; i++) {
            rs += Math.pow(2, i) * (ints[i] % 3);
        }
        return rs;
    }

    public static void main(String[] args) {
        System.out.println(new JZ56_II().singleNumber(new int[]{1, 1, 6, 1}));
    }
}
